#include <iostream>
using namespace std;
int main()
{
    int n;
    string s;
    char c;
    cin>>n;
    for(int i = 0; i<n; i++)
    {
        cin>>s>>c;
        string r = "";
        for(int i = 0; i<s.size(); i++)
            if(s[i] != c)
                r = r + s[i];
        if(r == "")
            cout<<"NULL"<<endl;
        else
            cout<<r<<endl;
    }
}